var fid = getUrlMsg()
var baseUrl = "http://47.102.45.219:8080/Appoint/Appoint/FeastSecServlet/selectByAdmin"
var update = "http://47.102.45.219:8080/Appoint/Appoint/FeastSecServlet/updateFeastByAdmin"
$(function () {

	//alert(fid)
	readMsg()
})

function getUrlMsg() {
	var str = location.href;
	var num = str.indexOf("=");
	str = str.substr(num + 1, 1)
	fid = str

	return str;

}

//根据id查询饭局
function selectFeastById(fid) {
	var flist;

	$.ajax({
		url: baseUrl,
		data: {
			"fid": fid
		},
		success: function (data) {
			if (data.statu) {
				flist = data.data
				listall = data.data[0]
				//alert(listall)
			} else {
				alert(data.msg)
			}
		},
		dataType: "json",
		type: 'post',
		statusCode: {
			404: function () {
				alert('page not found');
			}
		},
		xhrFields: {
			withCredentials: true
		},
		async: false
	})
	return listall;
}

function readMsg() {
	var flist = selectFeastById(fid)
	var f_title = eval(flist).f_title
	$("#f_title").val(f_title)

	var f_city = eval(flist).f_city
	$("#f_city").val(f_city)

	var f_num = eval(flist).f_num
	$("#f_num").val(f_num)

	var f_price = eval(flist).f_price
	$("#f_price").val(f_price)

	var f_address = eval(flist).f_address
	$("#f_address").val(f_address)

	var f_play = eval(flist).f_play
	$("#f_play").val(f_play)

	var f_lab = eval(flist).f_lab
	$("#f_lab").val(f_lab)

	var f_interest = eval(flist).f_interest
	$("#f_interesting").val(f_interest)
}


//修改方法
function updateMsg() {
	$.ajax({
		url: baseUrl,
		data: {
			"fid": fid
		},
		success: function (data) {
			if (data.statu) {
				flist = data.data
				listall = data.data[0]
				//alert(listall)
			} else {
				alert(data.msg)
			}
		},
		dataType: "json",
		type: 'post',
		statusCode: {
			404: function () {
				alert('page not found');
			}
		},
		xhrFields: {
			withCredentials: true
		},
		async: false
	})
}

function closeTest() {
	var f_title = $("#f_title").val()
	var f_city = $("#f_city").val()
	var f_num = $("#f_num").val()
	var f_price = $("#f_price").val()
	var f_address = $("#f_address").val()
	var f_play = $("#f_play").val()
	var f_lab = $("#f_lab").val()
	var f_interest = $("#f_interesting").val()

	$.ajax({
		url: update,
		data: {
			"fid": fid,
			"f_title": f_title,
			"f_city": f_city,
			"f_num": f_num,
			"f_price": f_price,
			"f_address": f_address,
			"f_play": f_play,
			"f_lab": f_lab,
			"f_interest": f_interest,
		},
		success: function (data) {
			if (data.statu) {
				xadmin.close();
				xadmin.father_reload();
			} else {
				alert(data.msg)
			}
		},
		dataType: "json",
		type: 'post',
		statusCode: {
			404: function () {
				alert('page not found');
			}
		},
		xhrFields: {
			withCredentials: true
		},
		async: false
	})


}